using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SpriteTextManager : MonoBehaviour
{
    public static SpriteTextManager instance;

    public GameObject textPrefab;
    public GameObject EffectTextPrefab;

    public static void NewDamageNumber(float damage, float x, float y)
    {
        GameObject newText = Instantiate(instance.textPrefab, new Vector3(x, y + 3.8f, 0), Quaternion.Euler(-60, 0, 0));
        newText.GetComponent<SpriteText>().Init(damage);
    }


    static int Num
    {
        set
        {
            if (value >= 4)
                _Num = 0;
            else
                _Num = value;
        }
        get
        {
            return _Num;
        }
    }
    static int _Num;
    public static void NewEffectText(string text, float x, float y, Color color)
    {
        Vector3 offset = posDic[Num];
        Num ++;
        GameObject newText = Instantiate(instance.EffectTextPrefab, new Vector3(x + offset.x, y + offset.y, 0), Quaternion.Euler(-60, 0, 0));
        newText.GetComponent<SpriteText>().Init(text, color);
    }

    private void Start()
    {
        instance = this;
    }

    static Dictionary<int, Vector3> posDic = new Dictionary<int, Vector3>
    {
        [0] = new Vector3(0, -3.8f, 0),
        [1] = new Vector3(-2.4f, -3.8f, 0),
        [2] = new Vector3(2.4f, -5.8f, 0),
        [3] = new Vector3(0, 5.8f, 0),
    };

}
